<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title> CallLib </title>
  <link rel="stylesheet" href="../res/rongcloud.css">
  <link rel="stylesheet" href="style/main.css">
</head>
<body>
  <div class="rong-container"></div>
   <div class="rong-toolbar">
      <button onclick="callVideo()" class="rong-callvideo"></button>
      <button onclick="callAudio()" class="rong-callaudio"></button>
      
      <button onclick="acceptVideo()" class="rong-accept"></button>
      <button onclick="hungup()" class="rong-hungup"></button>
      
      <button onclick="mute()" class="rong-mute"></button>
      <button onclick="unmute()" class="rong-unmute"></button>

      <button onclick="videoToAudio()" class="rong-disable-video"></button>
      <button onclick="audioToVideo()" class="rong-disable-audio"></button>
  </div>
  <h2 class="rong-notice">公告：此 Demo 即将废弃，后续不再维护，同时会推出新示例</h2>
  <div class="rong-warns">
    <p>兼容说明：</p>
    <ul>
      <li>操作系统: macOS 10.13.3+ 、Win7+</li>
      <li>浏览器: Chrome 57+</li>
    </ul>
    <p>站点要求：</p>
    <ul>
      <li>HTTPS 站点或 localhost, 端口不限</li>
    </ul>
  </div>
</body>
  <script src="//cdn.ronghub.com/RongIMLib-2.5.1.js"></script>
  <script src="//cdn.ronghub.com/RongCallLib-3.0.2.min.js"></script>
  <script src="./init.js"></script>
  <script src="./demo.js"></script>
  <script>
    var config = {
      appKey: 'appkey',
      users: [{
        id: "XD1n7p",
        token: "48WQusfOlwuO8bLvftw4xaa/DrZEyJMsLZ9PPIg+8Ph5+QmAtoP6tdpZUyLdaH"
      }, {
        id: "QlyBdT",
        token: "KM7HOjWA2JPgQUF0r+usAKE4ovwvabHEXU8xDrUJSvFtsdS1YEkeV2IKH+AY1qZPXnLINfK"
      }]
    };

    var params = (function(config){
        var users = config.users;  
        var appKey = config.appKey;

        var index = location.search.slice(1) || 0;
        var user = users[index];
        var inviteUsers = users.filter(function(_user){
          return _user.id != user.id;
        });
        var inviteUserIds = inviteUsers.map(function(_user){
          return _user.id; 
        });
        return {
          appKey: appKey,
          conversationType: 1,
          userId: user.id,
          inviteUserIds: inviteUserIds,
          token: user.token,
          targetId: inviteUsers[0].id
        };
    })(config);

    var callbacks = {
        getInstance : function(instance){
           var toolbar = tools.getDom('.rong-toolbar')[0];
           toolbar.style.display = 'block';
        },
        getCurrentUser : function(userInfo){
            console.log(userInfo.userId);
        }
    };

    IMLib.init(params, callbacks);
  </script>

</html> 